package com.world.web.controller.wifi;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.world.common.annotation.Log;
import com.world.common.core.controller.BaseController;
import com.world.common.core.domain.AjaxResult;
import com.world.common.enums.BusinessType;
import com.world.wifi.domain.WifiCost;
import com.world.wifi.service.IWifiCostService;
import com.world.common.utils.poi.ExcelUtil;
import com.world.common.core.page.TableDataInfo;

/**
 * 计费信息Controller
 * 
 * @author LiJunXi
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/wifi/cost")
public class WifiCostController extends BaseController
{
    @Autowired
    private IWifiCostService wifiCostService;

    /**
     * 查询计费信息列表
     */
    @PreAuthorize("@ss.hasPermi('wifi:cost:list')")
    @GetMapping("/list")
    public TableDataInfo list(WifiCost wifiCost)
    {
        startPage();
        List<WifiCost> list = wifiCostService.selectWifiCostList(wifiCost);
        return getDataTable(list);
    }

    /**
     * 导出计费信息列表
     */
    @PreAuthorize("@ss.hasPermi('wifi:cost:export')")
    @Log(title = "计费信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WifiCost wifiCost)
    {
        List<WifiCost> list = wifiCostService.selectWifiCostList(wifiCost);
        ExcelUtil<WifiCost> util = new ExcelUtil<WifiCost>(WifiCost.class);
        util.exportExcel(response, list, "计费信息数据");
    }

    /**
     * 获取计费信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('wifi:cost:query')")
    @GetMapping(value = "/{costId}")
    public AjaxResult getInfo(@PathVariable("costId") Long costId)
    {
        return success(wifiCostService.selectWifiCostByCostId(costId));
    }

    /**
     * 新增计费信息
     */
    @PreAuthorize("@ss.hasPermi('wifi:cost:add')")
    @Log(title = "计费信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WifiCost wifiCost)
    {
        return toAjax(wifiCostService.insertWifiCost(wifiCost));
    }

    /**
     * 修改计费信息
     */
    @PreAuthorize("@ss.hasPermi('wifi:cost:edit')")
    @Log(title = "计费信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WifiCost wifiCost)
    {
        return toAjax(wifiCostService.updateWifiCost(wifiCost));
    }

    /**
     * 删除计费信息
     */
    @PreAuthorize("@ss.hasPermi('wifi:cost:remove')")
    @Log(title = "计费信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{costIds}")
    public AjaxResult remove(@PathVariable Long[] costIds)
    {
        return toAjax(wifiCostService.deleteWifiCostByCostIds(costIds));
    }
}
